<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
<link type="text/css" href="css/jquery-ui-1.8.20custom.css" rel="stylesheet" />
</h:head>

<h:body  style="background-color: #e3fff6;" >

	<h:form id="form01">
	
	<p:panel header="Cadastro de Pessoas" style="font-size:13px;" >
			<p:growl id="growl" autoUpdate="true" showDetail="false" sticky="true" />
			  
    
		<h:panelGrid id="cadastro" columns="6">
		
			<h:outputText value="Nome:"/>
			<p:inputText value="#{pessoaMB.pessoa.nome}" required="true" requiredMessage="Nome Obrigatorio"/>	
			
			<h:outputText value="Endereco:"/>
			<p:inputText value="#{pessoaMB.pessoa.endereco}"/>
			
					  <h:outputText value="Cidade: " />
						<p:selectOneMenu value="#{pessoaMB.idCidade}"  required="true" requiredMessage="Cidade Obrigatorio">
								<f:selectItem itemLabel="-----" itemValue="" />
							<f:selectItems value="#{pessoaMB.cidadeList}" var="est"
								itemLabel="#{est.nome}" itemValue="#{est.id}" />
						</p:selectOneMenu>	
			
			
			<h:outputText value="Dada:"/>
			<p:calendar value="#{pessoaMB.pessoa.datanas}" />	
			
			<h:outputText value="Email:"/>
			<p:inputText value="#{pessoaMB.pessoa.email}"/>	
			
			<h:outputText value="Telefone:" requiredMessage="Digite um numero"/>
			<p:inputMask value="#{pessoaMB.pessoa.telefone}" mask="(99)9999-9999"/>	
			
					<h:outputText value="Senha:"/>
			<p:password  value="#{pessoaMB.pessoa.senha}" feedback="true" required="true" requiredMessage="Senha Obrigatoria"/>	
	
		</h:panelGrid>
		
			<p:commandButton value="Salvar" action="#{pessoaMB.salvar}"  actionListener="$bean.clearValues" update="form01" style="font-size:13px;" >
			<f:ajax execute="@form" render="@form" />
			</p:commandButton>
		
			<p:commandButton value="Excluir" action="#{pessoaMB.excluir}" actionListener="$bean.clearValues" update="form01" style="font-size:13px;" immediate="true">
				<f:ajax execute="@form" render="@form" />
			</p:commandButton>
			
				<p:link outcome="menu.jsf" value="Voltar ao Menu">
			</p:link>
			
			
			<p:panel header="Lista de Pessoas" style="font-size:13px;" >
			
			<p:dataTable var="c" value="#{pessoaMB.pessoaList}" widgetVar="pessoaTable" filteredValue="#{pessoaMB.pessoaListpessoa}" 
			 paginator="true" rows="10"  rowsPerPageTemplate="5 10 15 20" >
			 
		  <f:facet name="header">
            <p:outputPanel>
                <h:outputText value="Pesquisa:" />
                <p:inputText id="globalFilter" onkeyup="PF('pessoaTable').filter()" style="width:150px" placeholder="Enter keyword"/>
            </p:outputPanel>
        </f:facet>
			
			
		 <p:column filterBy="#{c.id}" headerText="Id">  
                
                <h:outputText value="#{c.id}" filterMatchMode="contains"/>  
            </p:column> 
	
			<p:column headerText="Nome" filterBy="#{c.nome}" >
			<p:outputLabel value="#{c.nome}" />
			</p:column>
			
			<p:column headerText="Data" filterBy="c.datanas">
			<p:outputLabel value="#{c.datanas}"/>
			</p:column>
			
			<p:column headerText="Email" filterBy="c.email">
				<p:outputLabel value="#{c.email}"/>
			</p:column>
			
			<p:column headerText="Telefone" filterBy="c.telefone"> 
					<p:outputLabel value="#{c.telefone}"/>
			</p:column>
			
				<p:column headerText="Endereço" filterBy="c.endereco">
				<p:outputLabel value="#{c.endereco}"/>
			</p:column>
						
			<p:column headerText="Cidade" filterBy="c.idCidade.nome">
				<p:outputLabel value="#{c.idCidade.nome}"/>
   			</p:column>
						
			
			<p:column headerText="Senha" filterBy="c.senha">
					<p:outputLabel value="#{c.senha}"/>
			</p:column>
			
			<p:column>
					<f:facet name="header">Editar</f:facet>
					<p:commandButton process="@this" value="Editar" update=":form01" >
						<f:setPropertyActionListener target="#{pessoaMB.pessoa}"
						value="#{c}" />
					</p:commandButton>
			</p:column>
			

		</p:dataTable>
		
	</p:panel>
	</p:panel>
	</h:form>
	
</h:body>
</html>